﻿using FastReport;
using FastReport.Utils;
using SMALLERP;
using SMALLERP.DataClass;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace XJLSC.PM
{
    public partial class LLDPrint : Form
    {
        DataBase db;
        private OleDbDataReader sdr;
        private Report FReport;
        private DataSet FDataSet;
        private Report FReport1;
        private DataSet FDataSet1;
        public delegate void Cdssh(object sender, EventArgs e);
        //定义委托对象
        public Cdssh cdssh;

        public LLDPrint()
        {
            InitializeComponent();
        }

        private void LLDPrint_Load(object sender, EventArgs e)
        {
            DataTable dt;
            int i;
            FDataSet = new DataSet();
            FReport = new Report();
            FReport.Preview = preview1;
            string thisFolder = Config.ApplicationFolder;
            DirectoryInfo theFolder = new DirectoryInfo(thisFolder + @"Reports\");
            string reportName = "";
            if (JYCX.DB == "5D10")
            {
                reportName = theFolder + "领料申请单.frx";
                this.Text = "领料申请单打印";
                
            }
            else
            {
                reportName = theFolder + "退料申请单.frx";
                this.Text = "退料申请单打印";
            }
            string strSql = null;
            db = new DataBase();
            if(JYCX.DB=="5D10")
            {
                strSql = "SELECT DISTINCT RTRIM(A.DOC_NO) 申请单号,C.DOC_NO 工单号,B.WAREHOUSE_CODE 仓库编号,B.WAREHOUSE_NAME 仓库名称 FROM MO_TEMP_LTL A LEFT JOIN WAREHOUSE B ON A.WAREHOUSE_ID=B.WAREHOUSE_ID LEFT JOIN MO C ON C.MO_ID=A.MO_ID WHERE A.DLH='" + JYCX.DH + "'";
            }
            else
            {
                strSql = "SELECT DISTINCT RTRIM(A.DOC_NO) 申请单号,C.DOC_NO 工单号,B.WAREHOUSE_CODE 仓库编号,B.WAREHOUSE_NAME 仓库名称 FROM MO_TEMP_LTL A LEFT JOIN WAREHOUSE B ON A.WAREHOUSE_ID=B.WAREHOUSE_ID LEFT JOIN MO C ON C.MO_ID=A.MO_ID WHERE A.DLH='" + JYCX.DH + "'";
            }
      
            FDataSet = db.GetDataSet1(strSql, "Table");
            dt = db.GetDataSet1(strSql, "PDATE").Tables["PDATE"];
            FReport.Load(reportName);
            FReport.RegisterData(FDataSet);
            FReport.Prepare();
            FReport.ShowPrepared();
           
        }
    }
}
